<html>
<head>
    <link href="css/main.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/api.js"> </script>    
    <script type="text/javascript" src="js/action.js"> </script>
    <script type="text/javascript">
        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return unescape(pair[1]);
                }
            }
            return null;
        }
        var word = getQueryVariable("word");
        var user = getQueryVariable("user");
        setTimeout("document.getElementById('word').innerHTML = word;", 100);

        function initUser() {
			var shanbay = new ShanbayAPI();
            var loginNotice = '<span class="user">Please <a href="#" onclick="goURL(\'' + shanbay.getLoginURL() + '\')">login</a> first.</span>';
            if (user) {
                welcomeMessage = '<span class="user">Welcome back, <a href="#" onclick="goURL(\"' + shanbay.getUserURL(user) + '\")">' + user + '</a></span>';
            } else {
                welcomeMessage = loginNotice;
            }
            var welcome = document.getElementById('welcome');
            welcome.innerHTML = welcomeMessage;
        }
		
		function add() {
			addSelected(word);
		}
    </script>
</head>
<body onload="initUser()">
<div id="container">
	<div class="user line">
		<img src="img/icon_16.png" class="content" />
		<span id="welcome" class="content" />
    </div>
    <div class="line">
        <div class="word content">word: <span id="word"></span></div>
        <div class="op content"><input type="button" onclick="add()" value=" Add " /></div>
	</div>
    <div id="notice" class="notice line">&nbsp;
    </div>
</div>
</body>
</html>
